package com.sikao.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sikao.app.R;
import com.sikao.app.bean.AuctionLogListBean;
import com.sikao.app.bean.ProductIndexBean;
import com.sikao.app.utils.TimeUtil;

import java.util.List;

/**
 * 首页里的拍卖详情内的 出价记录的adapter
 */
public class AuctionOrderListAdapter extends BaseAdapter {

	private Context context;
	List<AuctionLogListBean.ResBean.ListBean> auctionLogList;//需要修改成 最新的出价记录的bean
	public AuctionOrderListAdapter(Context context, List<AuctionLogListBean.ResBean.ListBean> auctionLogList){
		this.context = context;
		this.auctionLogList=auctionLogList;
	}
	@Override
	public int getCount() {
		return auctionLogList.size();
	}

	@Override
	public Object getItem(int position) {
		return  auctionLogList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		 if(convertView==null){
			 convertView = View.inflate(context, R.layout.aution_order_list_item,null);
			 convertView.setTag(new ViewHolder(convertView));
		 }
		 initializeViews((AuctionLogListBean.ResBean.ListBean)getItem(position), (ViewHolder) convertView.getTag());

		return convertView;
	}

	private void initializeViews(AuctionLogListBean.ResBean.ListBean auctionLogBean, ViewHolder viewHolder) {
		 viewHolder.tvPhone.setText(auctionLogBean.getPhone()+"");
	     viewHolder.tvOrderTime.setText(TimeUtil.timeStampToTime(auctionLogBean.getAdd_time(),TimeUtil.fotmatString1));
	     viewHolder.tvOrderContent.setText(auctionLogBean.getTotal_amount()+"");
	     //viewHolder.tvOrderTime.setText(auctionLogBean.getDefault_value_toString());

	}

	protected class ViewHolder {
		private TextView tvPhone;
		private TextView tvOrderTime;
		private TextView tvOrderContent;
		private TextView tvOrderState;

		public ViewHolder(View view) {
			tvPhone = (TextView) view.findViewById(R.id.tv_phone);
			tvOrderTime = (TextView) view.findViewById(R.id.tv_order_time);
			tvOrderContent = (TextView) view.findViewById(R.id.tv_order_content);
			tvOrderState = (TextView) view.findViewById(R.id.tv_order_state);
		}
	}
}
